#include "choselevescene.h"
#include<QPainter>
#include<QMenuBar>
#include<mypushbutton.h>
#include<QDebug>
#include<QTimer>
#include<QLabel>


choselevescene::choselevescene(QWidget *parent) : QMainWindow(parent)
{
    //配置
    this->setFixedSize(400,688);
    //设置图标
    setWindowIcon(QIcon(":/2tb.jpg"));
    setWindowTitle("choosing");
    //开始退出
    QMenuBar*bar=menuBar();
    setMenuBar(bar);
    QMenu*startmenu=bar->addMenu("开始");
    QAction*quitaction=startmenu->addAction("退出");
    connect(quitaction,&QAction::triggered,[=](){
        this->close();
    });
    //返回按钮
    mypushbutton* backbtn=new mypushbutton(":/back.jfif");
    backbtn->setParent(this);
    backbtn->setFixedSize(40,40);
    backbtn->move(this->width()-backbtn->width(),this->height()-backbtn->height());
    connect(backbtn,&mypushbutton::clicked,[=](){
        qDebug()<<"back";
        QTimer::singleShot(200,this,[=](){
            emit this->choosesenceback();
        });

    });
    for(int i=0;i<20;i++)
    {
        mypushbutton*menubtn=new mypushbutton(":/gq.jpg");
        menubtn->setParent(this);
        menubtn->move(25+i%4*80,130+i/4*80);
        connect(menubtn,&mypushbutton::clicked,[=](){
            QString str=QString("您选择的是第%1关").arg(i+1);
            qDebug()<<str;
            //进入游戏
            this->hide();
            play=new playsence(i+1);
            play->show();
        });

        QLabel*label=new QLabel;
        label->setParent(this);
        label->setFixedSize(menubtn->width(),menubtn->height());
        label->setText(QString::number(1+i));
        label->move(88+i%4*80,130+i/4*80);

    }


}
 void choselevescene::paintEvent(QPaintEvent*){
     QPainter painter(this);
     QPixmap pix;
     pix.load(":/bj2.jpg");
     painter.drawPixmap(0,0,this->width(),this->height(),pix);
     pix.load(":/bt.png");
     painter.drawPixmap(-10,0,pix);

 }

